:root {
    --primary: #4a6fa5;
    --primary-light: #6b8cb8;
    --primary-dark: #3a5a8c;
    --work: #3498db;
    --rest: #2ecc71;
    --solve: #e74c3c;
    --pause: #f39c12;
    --bg: #f0f2f5;
    --card: #ffffff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.08);
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --border: #e1e4e8;
    --gray: #9aa0a6;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--dark);
    min-height: 100vh;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    flex-grow: 1;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    color: var(--primary-dark);
    text-align: center;
    font-weight: 600;
}

.card {
    background: var(--card);
    border-radius: 16px;
    width: 99.8%;
    margin: 0 auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 16px;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.timer-display {
    text-align: center;
    margin: 40px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.timer {
    font-size: 6rem;
    font-weight: 700;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    color: var(--dark);
    letter-spacing: -2px;
    transition: var(--transition);
}

.timer:hover {
    transform: scale(1.02);
}

.status {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--primary);
    font-weight: 500;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #27ae60;
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background-color: #d35400;
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background-color: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background-color: #dcdfe6;
    transform: translateY(-3px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chart-container {
    height: 280px;
    margin: 20px 0;
    border-radius: 12px;
    background-color: white;
    padding: 10px;
    box-shadow: var(--shadow);
    flex: 1 1 auto;
}

.period-btn {
    padding: 8px 16px;
    background-color: var(--light);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.period-btn.active {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

.period-btn:hover:not(.active) {
    background-color: #e1e4e8;
    transform: translateY(-2px);
}

.details-content {
    width: 100%;
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin: 20px 0;
    height: 360px;
    flex: 1 1 auto;
}

.stats-grid {
    flex: 0 0 320px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 0;
    height: 100%;
}

.chart-container {
    flex: 1;
    height: 100%;
    margin: 0;
    border-radius: 12px;
    background-color: white;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card {
    background-color: white;
    padding: 18px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.stat-card.work::before { background-color: var(--work); }
.stat-card.rest::before { background-color: var(--rest); }
.stat-card.solve::before { background-color: var(--solve); }
.stat-card.sessions::before { background-color: var(--primary); }

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon.work {
    background-color: rgba(52, 152, 219, 0.15);
    color: var(--work);
}

.stat-icon.rest {
    background-color: rgba(46, 204, 113, 0.15);
    color: var(--rest);
}

.stat-icon.solve {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--solve);
}

.stat-icon.sessions {
    background-color: rgba(74, 111, 165, 0.15);
    color: var(--primary);
}

.stat-info {
    flex-grow: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-dark);
    margin-bottom: 4px;
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray);
}

.notification {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background-color: var(--primary);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
    animation: slideUp 0.3s ease forwards;
    font-weight: 500;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--warning);
    color: white;
    font-size: 12px;
    margin-left: 6px;
    cursor: help;
    position: relative;
}

.info-tooltip {
    visibility: hidden;
    width: 220px;
    background-color: var(--dark);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px 10px;
    position: absolute;
    z-index: 1000;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 12px;
    font-weight: normal;
    pointer-events: none;
}

.info-icon:hover .info-tooltip {
    visibility: visible;
    opacity: 1;
}

.info-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--dark) transparent transparent transparent;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.data-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px;
    background-color: white;
    border-radius: 12px;
    margin: 20px 0;
    /* box-shadow: var(--shadow); */
}

.date-selector{
    position: absolute;
    left: 50%;
    transform: translate(-49%, 0%);
}

.date-input {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    min-width: 140px;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

.date-nav-btn {
    background-color: var(--light);
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.date-nav-btn:hover {
    background-color: #dcdfe6;
    transform: translateY(-2px);
}

.data-actions {
    margin-right: auto;
    white-space: nowrap;
    text-align: center;
    display: flex;
    gap: 16px;
    padding: 15px;
    background-color: white;
    border-radius: 12px;
}

.clear-data-btn {
    background-color: var(--danger);
    color: white;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.clear-data-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.import-export-btn, .export-export-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.import-export-btn {
    background-color: var(--rest);
    color: white;
}

.export-export-btn {
    background-color: var(--primary);
    color: white;
}

.import-export-btn:hover, .export-export-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

#file-input {
    display: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    display: none;
    backdrop-filter: blur(5px);
}

.modal {
    background-color: white;
    padding: 28px;
    border-radius: 14px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal h3 {
    margin-bottom: 18px;
    color: var(--dark);
    font-size: 1.3rem;
}

.modal p {
    margin-bottom: 24px;
    color: var(--dark);
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
}

.bottom-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 60px;
    margin-top: auto;
    padding: 20px 0 10px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    transform: translateY(-3px);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
    color: var(--gray);
    transition: var(--transition);
}

.nav-item.active .nav-icon {
    color: var(--primary);
}

.nav-line {
    width: 24px;
    height: 4px;
    border-radius: 2px;
    background-color: transparent;
    margin-top: 6px;
    transition: var(--transition);
}

.nav-item.active .nav-line {
    background-color: var(--primary);
    width: 32px;
}

.nav-label {
    font-size: 0.9rem;
    color: var(--gray);
    transition: var(--transition);
}

.nav-item.active .nav-label {
    color: var(--primary);
    font-weight: 500;
}

.settings-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 40px;
    margin: 10px 0;
    justify-content: center;
}

.settings-row {
    display: flex;
    width: 100%;
}

.settings-row.first {
    justify-content: flex-start;
}

.settings-row.second {
    justify-content: flex-end;
}

.settings-group {
    display: flex;
    gap: 60px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.setting-label {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: 500;
    display: flex;
    align-items: center;
}

.setting-input {
    position: relative;
}

.time-input {
    width: 100%;
    padding: 14px 16px;
    padding-right: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    transition: var(--transition);
}

.time-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

.time-unit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 1.1rem;
}

.notification-input {
    width: 22px;
    height: 22px;
    margin-top: 5px;
    accent-color: var(--primary);
}

.settings-actions {
    margin-top: 40px;
    text-align: center;
}

.save-settings {
    background-color: var(--primary);
    color: white;
    padding: 14px 32px;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
    font-size: 1.05rem;
}

.save-settings:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

/* 每个界面占据容器剩余空间（底部导航不覆盖） */
.interface {
    flex: 1 1 auto;
    display: none; /* 通过 .active 切换显示 */
    width: 100%;
    box-sizing: border-box;
    overflow: auto; /* 内容超出时可滚动 */
}

.interface.active {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.clear-options {
    margin: 20px 0;
    text-align: left;
}

.clear-option {
    display: block;
    margin-bottom: 12px;
    padding-left: 5px;
    font-size: 0.95rem;
}

.clear-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--danger);
}

.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    stroke-width: 0;
    stroke: currentColor;
    fill: currentColor;
}

.period-selector {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

.period-select-btn {
    padding: 10px 16px;
    background-color: var(--light);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 100px;
}

.period-select-btn:hover {
    background-color: #e1e4e8;
}

.period-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 100%;
    margin-top: 5px;
    overflow: hidden;
    display: none;
}

.period-dropdown.show {
    display: block;
}

.period-option {
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    text-align: right;
}

.period-option:hover {
    background-color: var(--light);
}

.period-option.active {
    background-color: var(--primary-light);
    color: white;
}

.caret-icon {
    transition: transform 0.3s ease;
}

.period-select-btn.open .caret-icon {
    transform: rotate(180deg);
}

.settings-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    width: 100%;
}

.divider-line {
    flex: 1;
    height: 1px;
    background-color: var(--border);
}

.divider-text {
    padding: 0 16px;
    font-size: 0.9rem;
    color: var(--gray);
    white-space: nowrap;
}

.settings-row {
    display: flex;
    justify-content: center;
    gap: 60px;
    width: 100%;
    margin: 5px 0;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 220px;
}

.setting-label {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.setting-item:hover .setting-label {
    color: var(--primary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    margin-top: 5px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--light);
    transition: var(--transition);
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.time-input-group {
    position: relative;
    overflow: hidden;
}

.time-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-inputs .time-input {
    flex: 1;
    padding-right: 20px;
}

.time-separator {
    font-size: 1.5rem;
    color: var(--gray);
    font-weight: bold;
}

.time-subunit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 0.9rem;
}

.minutes-container {
    position: relative;
    flex: 1;
}

.seconds-container {
    position: relative;
    flex: 1;
}

.time-input:focus ~ .input-highlight {
    width: 100%;
}

.input-highlight {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: var(--transition);
}

/* 计划界面样式 */
#plan-interface .card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.plan-date-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.plan-date-input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    min-width: 180px;
}

.plan-table-container {
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: white;
    box-shadow: var(--shadow);
    padding: 10px;
    flex: 1 1 auto;
}

.plan-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.plan-table th,
.plan-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.plan-table th {
    font-weight: 600;
    color: var(--primary-dark);
    background-color: rgba(74, 111, 165, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.plan-table tr:hover {
    background-color: rgba(74, 111, 165, 0.03);
}

.plan-table tr.selected {
    background-color: rgba(52, 152, 219, 0.1);
}

.plan-table tr.dragging {
    opacity: 0.7;
    background-color: rgba(74, 111, 165, 0.1);
}

.plan-table .drag-handle {
    cursor: move;
    color: var(--gray);
    padding-right: 10px;
}

.plan-table .drag-handle:hover {
    color: var(--primary);
}

.plan-table input,
.plan-table select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.plan-table input:focus,
.plan-table select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

.time-inputs.plan-time {
    gap: 5px;
}

.time-inputs.plan-time input {
    flex: 1;
    text-align: center;
}

.plan-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.tag-color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* 标签管理样式 */
.tag-management {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background-color: var(--light);
    border-radius: 8px;
}

.tag-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tag-color-picker {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}

.tag-name-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    flex-grow: 1;
}

.template-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background-color: var(--light);
    border-radius: 8px;
}

.template-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-template-btn,
.add-tag-btn {
    background-color: var(--primary-light);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.delete-btn {
    color: var(--danger);
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.delete-btn:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.template-management {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.add-plan-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 10px 0;
}

.add-plan-option {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.add-plan-option:hover {
    background-color: var(--light);
    border-color: var(--primary-light);
}

.template-selector {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.template-select-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
}

.template-select-item:hover {
    background-color: var(--light);
}

.checkbox-cell {
    width: 40px;
}

.checkbox-cell input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}